{template 'header', $module}
<script type="text/javascript">menuChanger('menu_pay');var errimg = '{CSSIMG_URL}/common/nopic50.gif';</script>


<div class="hd fn-clear">
    <h2 class="fn-left">交易管理</h2>
</div>
<ul id="data-nav" class="main-nav mt10 fn-clear">
    <li id="status_"><a href="{url('member/trade')}?mid={$mid}&action=pay"><span>我要付款</span></a></li>
    <li id="status_3"><a href="{url('member/trade')}?status=3"><span>收到的订单(卖)</span></a></li>
    <li id="status_2"><a href="{url('member/trade')}?action=order&status=2"><span>发出的订单(买)</span></a></li>
    {if isset($MODULE[17])}
    <li id="status_1"><a href="{url('member/trade')}?action=order&status=1"><span>{$MODULE[17][name]}订单</span></a></li>
    {/if}
    {if 0&&$DT[trade]}
    <li id="status_4"><a href="{url('member/trade')}?action=bind&status=3"><span>绑定{$DT[trade_nm]}帐号</span></a></li>
    {/if}
</ul>

{if $action == 'pay'}
<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
	<input type="hidden" name="action" value="{$action}"/>
	<table class="data-form">
		<tr>
			<th width="90">帐户可用余额</th>
			<td class="tr"><strong class="f_blue">{$_money}</strong></td>
		</tr>
		<tr>
			<th width="90"><span class="cred">*</span> 收款会员名</th>
			<td class="tr"><input type="text" size="15" name="seller" id="seller" onblur="get_company();"/>&nbsp; <a href="javascript:Diframe('{$MOD[linkurl]}friend.php?action=my&obj=seller', '450', 0, 1, '我的好友');" class="t">[我的好友]</a> &nbsp;<span id="dseller" class="cred"></span>&nbsp;<span
					id="company" class="cred"></span></td>
		</tr>
		<tr>
			<th width="90"><span class="cred">*</span> 付款金额</th>
			<td class="tr"><input type="text" size="10" name="amount" id="amount"/> {$DT[money_unit]}&nbsp;<span id="damount" class="cred"></span></td>
		</tr>
		<tr>
			<th width="90"><span class="cred">*</span> 支付密码</th>
			<td class="tr">{template 'password', 'chip'}&nbsp;<span id="dpassword" class="cred"></span></td>
		</tr>
		<tr>
			<th width="90">付款说明</th>
			<td class="tr"><input type="text" size="50" name="note" id="note"/>&nbsp;<span id="dnote" class="cred"></span></td>
		</tr>
		{if $_userid && $DT[sms]}
			<tr>
				<th width="90">短信通知</th>
				<td class="tr"><input type="checkbox" name="sendsms" value="1"/> 发送短信通知至收款人 (<a href="{$MODULE[2][linkurl]}sms.php" target="_blank">我的可用短信 <strong class="f_blue">{$_sms}</strong> 条</a>)</td>
			</tr>
		{/if}
		<tr>
			<th width="90">&nbsp;</th>
			<td class="tr" height="50"><input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="reset" value=" 重 置 " class="btn"/></td>
		</tr>
	</table>
</form>
	{load('clear.js')}
<script type="text/javascript">
	function check() {
		if ( Dd('seller').value == '' ) {
			Dmsg('请填写收款会员名', 'seller');
			return false;
		}
		if ( Dd('amount').value == '' ) {
			Dmsg('请填写付款金额', 'amount');
			return false;
		}
		if ( Dd('password').value.length < 6 ) {
			Dmsg('请填写支付密码', 'password');
			return false;
		}
		return confirm('注意:会员 ' + Dd('seller').value + ' 将直接收到您的付款\n\n确认填写无误，提交此请求吗？');

	}
	function get_company() {
		if ( Dd('seller').value ) {
			makeRequest('moduleid={$moduleid}&action=member&job=get_company&value=' + Dd('seller').value, 'ajax.php', '_get_company');
		}
	}
	function _get_company() {
		if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) {
			if ( xmlHttp.responseText == 1 ) {
				Dd('seller').value = '';
				Dd('company').innerHTML = '会员不存在,请确认';
			} else {
				Dd('company').innerHTML = xmlHttp.responseText;
			}
		}
	}
</script>
<script type="text/javascript">s('trade');
m('action_pay');</script>
	{elseif $action == 'bind'}
	{if $member[vtrade]}
	<table cellpadding="10" cellspacing="1" class="tb">
		<tr>
			<th width="90">{$DT[trade_nm]}帐号</th>
			<td class="tr"><strong>{$member[trade]}</strong></td>
		</tr>
		<tr>
			<th width="90">绑定状态</th>
			<td class="tr f_green">已验证</td>
		</tr>
		<tr>
			<th width="90">{$DT[trade_nm]}</th>
			<td class="tr"><a href="{$DT[trade_hm]}" target="_blank" class="l">交易管理</a></td>
		</tr>
	</table>
		{else}
	<form method="post" action="trade.php">
		<input type="hidden" name="action" value="{$action}"/>
		<table cellpadding="10" cellspacing="1" class="tb">
			<tr>
				<th width="90">{$DT[trade_nm]}网站</th>
				<td class="tr">
					还没有 <img src="{SITE_URL}api/trade/{$DT[trade]}/logo.gif" alt="{$DT[trade_nm]}" align="absmiddle"/> 会员帐号？ <a href="{$DT[trade_hm]}" target="_blank" class="l">点击了解和注册</a>
				</td>
			</tr>
			<tr>
				<th width="90">{$DT[trade_nm]}帐号</th>
				<td class="tr"><input type="text" size="30" name="trade" id="trade" value="{$member[trade]}"/> <input type="submit" name="submit" value="{if $member[trade]}更 新{else}绑 定{/if}" class="btn"/></td>
			</tr>
			<tr>
				<th width="90">绑定状态</th>
				<td class="tr cred">未验证</td>
			</tr>
			<tr>
				<th width="90">验证方法</th>
				<td class="tr f_gray">通过{$DT[trade_nm]}成功交易后系统自动验证</td>
			</tr>
			<tr>
				<th width="90">绑定说明</th>
				<td class="tr f_gray">卖家必须绑定{$DT[trade_nm]}帐号用于收款，买家无须绑定</td>
			</tr>
		</table>
	</form>
	{/if}
<script type="text/javascript">s('trade');
m('action_bind');</script>
	{elseif $action == 'update'}
	{if $step == 'edit_price'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">修改价格</td>
			</tr>
			<tr>
				<th width="90">订单单号</th>
				<td class="tr">T{$td[itemid]}</td>
			</tr>
			<tr>
				<th width="90">商品名称</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank" class="t">{$td[title]}</a></td>
			</tr>
			<tr>
				<th width="90">商品图片</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank"><img src="{if $td[thumb]}{$td[thumb]}{else}{CSSIMG_URL}/common/nopic60.gif{/if}" width="60" height="60"/></a></td>
			</tr>
			<tr>
				<th width="90">买家</th>
				<td class="tr"><a href="{userurl($td[buyer], 'file=contact')}" target="_blank" class="t">{$td[buyer]}</a></td>
			</tr>
			<tr>
				<th width="90">邮编</th>
				<td class="tr">{$td[buyer_postcode]}</td>
			</tr>
			<tr>
				<th width="90">地址</th>
				<td class="tr">{$td[buyer_address]}</td>
			</tr>
			<tr>
				<th width="90">收货人</th>
				<td class="tr">{$td[buyer_name]}</td>
			</tr>
			<tr>
				<th width="90">手机</th>
				<td class="tr">{$td[buyer_mobile]} {if $DT[sms]}&nbsp;&nbsp;<a href="sms.php?action=add&auth={Crypt::encode($td[buyer_mobile])}" target="_blank"><img src="{CSSIMG_URL}/common/sendsms.gif" align="absmiddle" title="发送短信" alt=""/></a>{/if}</td>
			</tr>
			<tr>
				<th width="90">电话</th>
				<td class="tr">{$td[buyer_phone]}</td>
			</tr>
			<tr>
				<th width="90">期望物流</th>
				<td class="tr">{$td[buyer_receive]}</td>
			</tr>
			<tr>
				<th width="90">买家备注</th>
				<td class="tr">{$td[note]}</td>
			</tr>
			<tr>
				<th width="90">下单时间</th>
				<td class="tr">{$td[adddate]}</td>
			</tr>
			<tr>
				<th width="90">商品单价</th>
				<td class="tr">￥{$td[price]}</td>
			</tr>
			<tr>
				<th width="90">购买数量</th>
				<td class="tr">{$td[number]}</td>
			</tr>
			<tr>
				<th width="90">订单金额</th>
				<td class="tr f_blue f_b">{$td[amount]} {$DT[money_unit]}</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>附加金额名称</th>
				<td class="tr f_gray"><input type="text" size="10" name="fee_name" id="fee_name" value="{$td[fee_name]}"/> 例如运费、退款、优惠等&nbsp;<span id="dfee_name" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>附加金额</th>
				<td class="tr f_gray"><input type="text" size="5" name="fee" id="fee" value="{$td[fee]}"/>  {$DT[money_unit]} 可以为负值&nbsp;<span id="dfee" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"></th>
				<td class="tr"><input type="checkbox" name="confirm_order" value="1"/> 同时确认订单 <span class="cred">[请谨慎，订单一经确定，将不可再修改]</span></td>
			</tr>
			{if $_userid && $DT[sms]}
				<tr>
					<th width="90"></th>
					<td class="tr"><input type="checkbox" name="sendsms" value="1"/> 短信通知买家订单确认 (<a href="{$MODULE[2][linkurl]}sms.php" target="_blank" class="t">我的可用短信 <strong class="f_blue">{$_sms}</strong> 条</a>)</td>
				</tr>
			{/if}
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			if ( !Dd('fee_name').value ) {
				Dmsg('请填写附加金额名称', 'fee_name');
				return false;
			}
			if ( !Dd('fee').value ) {
				Dmsg('请填写附加金额', 'fee');
				return false;
			}
			return true;
		}
	</script>
	<script type="text/javascript">s('trade');
	m('action');</script>
		{elseif $step == 'detail'}
	<table class="data-form">
		<tr>
			<th width="90">当前操作</th>
			<td class="tr cred f_b">订单详情</td>
		</tr>
		<tr>
			<th width="90">订单单号</th>
			<td class="tr">T{$td[itemid]} {if $DT[trade]}({$DT[trade_nm]}订单单号:{$td[trade_no]}){/if}</td>
		</tr>
		<tr>
			<th width="90">商品名称</th>
			<td class="tr"><a href="{$td[linkurl]}" target="_blank" class="t">{$td[title]}</a></td>
		</tr>
		<tr>
			<th width="90">商品图片</th>
			<td class="tr"><a href="{$td[linkurl]}" target="_blank"><img src="{if $td[thumb]}{$td[thumb]}{else}{CSSIMG_URL}/common/nopic60.gif{/if}" width="60" height="60"/></a></td>
		</tr>
		{if $td[seller] == $_username}
			<tr>
				<th width="90">买家</th>
				<td class="tr"><a href="{userurl($td[buyer], 'file=contact')}" target="_blank" class="t">{$td[buyer]}</a></td>
			</tr>
			{elseif $td[buyer] == $_username}
			<tr>
				<th width="90">卖家</th>
				<td class="tr"><a href="{userurl($td[seller], 'file=contact')}" target="_blank" class="t">{$td[seller]}</a></td>
			</tr>
		{/if}
		<tr>
			<th width="90">邮编</th>
			<td class="tr">{$td[buyer_postcode]}</td>
		</tr>
		<tr>
			<th width="90">地址</th>
			<td class="tr">{$td[buyer_address]}</td>
		</tr>
		<tr>
			<th width="90">收货人</th>
			<td class="tr">{$td[buyer_name]}</td>
		</tr>
		<tr>
			<th width="90">手机</th>
			<td class="tr">{$td[buyer_mobile]} {if $DT[sms]}&nbsp;&nbsp;<a href="sms.php?action=add&auth={Crypt::encode($td[buyer_mobile])}" target="_blank"><img src="{CSSIMG_URL}/common/sendsms.gif" align="absmiddle" title="发送短信" alt=""/></a>{/if}</td>
		</tr>
		<tr>
			<th width="90">电话</th>
			<td class="tr">{$td[buyer_phone]}</td>
		</tr>
		<tr>
			<th width="90">期望物流</th>
			<td class="tr">{$td[buyer_receive]}</td>
		</tr>
		<tr>
			<th width="90">买家备注</th>
			<td class="tr">{$td[note]}</td>
		</tr>
		<tr>
			<th width="90">下单时间</th>
			<td class="tr">{$td[adddate]}</td>
		</tr>
		<tr>
			<th width="90">最后更新</th>
			<td class="tr">{$td[updatedate]}</td>
		</tr>
		<tr>
			<th width="90">商品单价</th>
			<td class="tr">￥{$td[price]}</td>
		</tr>
		<tr>
			<th width="90">购买数量</th>
			<td class="tr">{$td[number]}</td>
		</tr>
		<tr>
			<th width="90">订单金额</th>
			<td class="tr cred">{$td[amount]}</td>
		</tr>
		{if $td[fee_name] && $td[fee]}
			<tr>
				<th width="90">{$td[fee_name]}</th>
				<td class="tr f_blue">{$td[fee]} {$DT[money_unit]}</td>
			</tr>
		{/if}
		<tr>
			<th width="90">订单总额</th>
			<td class="tr f_blue f_b">{$td[total]} {$DT[money_unit]}</td>
		</tr>
		<tr>
			<th width="90">物流类型</th>
			<td class="tr">{$td[send_type]}</td>
		</tr>
		<tr>
			<th width="90">物流号码</th>
			<td class="tr">{$td[send_no]}</td>
		</tr>
		<tr>
			<th width="90">发货时间</th>
			<td class="tr">{$td[send_time]}</td>
		</tr>
		<tr>
			<th width="90">订单状态</th>
			<td class="tr">{$_status[$td[status]]}</td>
		</tr>
		{if $td[buyer_reason]}
			<tr>
				<th width="90">退款理由</th>
				<td class="tr">{$td[buyer_reason]}</td>
			</tr>
		{/if}
		<tr>
			<th width="90"></th>
			<td class="tr"><input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
			</td>
		</tr>
	</table>
	</form>
	<script type="text/javascript">s('trade');
	m('{$nav}');</script>
		{elseif $step == 'pay'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">订单支付</td>
			</tr>
			<tr>
				<th width="90">订单单号</th>
				<td class="tr">T{$td[itemid]} {if $DT[trade]}({$DT[trade_nm]}订单单号:{$td[trade_no]}){/if}</td>
			</tr>
			<tr>
				<th width="90">商品名称</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank" class="t">{$td[title]}</a></td>
			</tr>
			<tr>
				<th width="90">商品图片</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank"><img src="{if $td[thumb]}{$td[thumb]}{else}{CSSIMG_URL}/common/nopic60.gif{/if}" width="60" height="60"/></a></td>
			</tr>
			<tr>
				<th width="90">卖家</th>
				<td class="tr"><a href="{userurl($td[seller], 'file=contact')}" target="_blank" class="t">{$td[seller]}</a></td>
			</tr>
			<tr>
				<th width="90">下单时间</th>
				<td class="tr">{$td[adddate]}</td>
			</tr>
			<tr>
				<th width="90">期望物流</th>
				<td class="tr">{$td[buyer_receive]}</td>
			</tr>
			<tr>
				<th width="90">我的备注</th>
				<td class="tr">{$td[note]}</td>
			</tr>
			<tr>
				<th width="90">商品单价</th>
				<td class="tr">￥{$td[price]}</td>
			</tr>
			<tr>
				<th width="90">购买数量</th>
				<td class="tr">{$td[number]}</td>
			</tr>
			<tr>
				<th width="90">订单金额</th>
				<td class="tr f_blue f_b">{$td[amount]} {$DT[money_unit]}</td>
			</tr>
			{if $td[fee]>0.1}
				<tr>
					<th width="90">{$td[fee_name]}</th>
					<td class="tr f_blue f_b">{$td[fee]} {$DT[money_unit]}</td>
				</tr>
			{/if}
			<tr>
				<th width="90">实付金额</th>
				<td class="tr cred f_b">{$money} {$DT[money_unit]}</td>
			</tr>
			<tr>
				<th width="90">帐户余额</th>
				<td class="tr f_b">{$_money} {$DT[money_unit]}</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span> 支付密码</th>
				<td class="tr">{template 'password', 'chip'}&nbsp;<span id="dpassword" class="cred"></span></td>
			</tr>
			{if $_userid && $DT[sms]}
				<tr>
					<th width="90"></th>
					<td class="tr"><input type="checkbox" name="sendsms" value="1"/> 短信通知卖家发货 (<a href="{$MODULE[2][linkurl]}sms.php" target="_blank" class="t">我的可用短信 <strong class="f_blue">{$_sms}</strong> 条</a>)</td>
				</tr>
			{/if}
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			if ( Dd('password').value == '' ) {
				Dmsg('请填写支付密码', 'password');
				return false;
			}
			return confirm('您确认此订单，并立即支付吗？');
		}
	</script>
	<script type="text/javascript">s('trade');
	m('action_order');</script>
		{elseif $step == 'send_goods'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">确认发货</td>
			</tr>
			{if $td[buyer_receive]}
				<tr>
					<th width="90">买家期望物流</th>
					<td class="tr cred f_b">{$td[buyer_receive]}</td>
				</tr>
			{/if}
			<tr>
				<th width="90">物流类型</th>
				<td class="tr f_gray"><input type="text" size="10" name="send_type" id="send_type"/>
					<select onchange="Dd('send_type').value=this.value;">
						<option value="">常用物流类型</option>
						{loop $send_types $v}
							<option value="{$v}">{$v}</option>
						{/loop}
					</select>
				</td>
			</tr>
			<tr>
				<th width="90">物流号码</th>
				<td class="tr f_gray"><input type="text" size="30" name="send_no" id="send_no"/></td>
			</tr>
			<tr>
				<th width="90">发货时间</th>
				<td class="tr f_gray"><input type="text" size="20" name="send_time" id="send_time" value="{$send_time}"/></td>
			</tr>
			{if $_userid && $DT[sms]}
				<tr>
					<th width="90"></th>
					<td class="tr"><input type="checkbox" name="sendsms" value="1"/> 短信通知买家已发货 (<a href="{$MODULE[2][linkurl]}sms.php" target="_blank" class="t">我的可用短信 <strong class="f_blue">{$_sms}</strong> 条</a>)</td>
				</tr>
			{/if}
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			return confirm('您确认货物已经发出，并且以上信息填写无误吗？\n\n此操作将不可撤销');
		}
	</script>
	<script type="text/javascript">s('trade');
	m('action');</script>
		{elseif $step == 'add_time'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">延长买家确认时间</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>延长时间</th>
				<td class="tr f_gray"><input type="text" size="10" name="add_time" id="add_time" value="{$td[add_time]}"/> 单位:小时 1天=24小时 只能为整数&nbsp;<span id="dadd_time" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			return confirm('您确认延长' + Dd('add_time').value + '小时吗？');
		}
	</script>
	<script type="text/javascript">s('trade');
	m('action');</script>
		{elseif $step == 'refund'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">申请退款</td>
			</tr>
			<tr>
				<th width="90">订单单号</th>
				<td class="tr">T{$td[itemid]} {if $DT[trade]}({$DT[trade_nm]}订单单号:{$td[trade_no]}){/if}</td>
			</tr>
			<tr>
				<th width="90">商品名称</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank" class="t">{$td[title]}</a></td>
			</tr>
			<tr>
				<th width="90">商品图片</th>
				<td class="tr"><a href="{$td[linkurl]}" target="_blank"><img src="{if $td[thumb]}{$td[thumb]}{else}{CSSIMG_URL}/common/nopic60.gif{/if}" width="60" height="60"/></a></td>
			</tr>
			<tr>
				<th width="90">卖家</th>
				<td class="tr"><a href="{userurl($td[seller], 'file=contact')}" target="_blank" class="t">{$td[seller]}</a></td>
			</tr>
			<tr>
				<th width="90">下单时间</th>
				<td class="tr">{$td[adddate]}</td>
			</tr>
			<tr>
				<th width="90">发货时间</th>
				<td class="tr">{$td[updatedate]}</td>
			</tr>
			<tr>
				<th width="90">备注说明</th>
				<td class="tr">{$td[note]}</td>
			</tr>
			<tr>
				<th width="90">订单金额</th>
				<td class="tr f_blue f_b">{$td[amount]} {$DT[money_unit]}</td>
			</tr>
			{if $td[fee]>0.1}
				<tr>
					<th width="90">{$td[fee_name]}</th>
					<td class="tr f_blue f_b">{$td[fee]} {$DT[money_unit]}</td>
				</tr>
			{/if}
			<tr>
				<th width="90">实付金额</th>
				<td class="tr cred f_b">{$money} {$DT[money_unit]}</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span> 理由及证据</th>
				<td class="tr"><textarea name="content" id="content" class="dsn"></textarea>
					{deditor($moduleid, 'content', 'Simple', '98%', 200)}<span id="dcontent" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span> 支付密码</th>
				<td class="tr">{template 'password', 'chip'}&nbsp;<span id="dpassword" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			var len = FCKLen();
			if ( len < 10 ) {
				Dmsg('理由及证据不能少于10个字，当前已输入' + len + '个字', 'content');
				return false;
			}
			if ( Dd('password').value == '' ) {
				Dmsg('请填写支付密码', 'password');
				return false;
			}
			return confirm('您确认您提供的理由及证据无误，并申请退款吗？');
		}
	</script>
	<script type="text/javascript">s('trade');
	m('action_order');</script>
		{elseif $step == 'comment'}
	<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
		<input type="hidden" name="forward" value="{$forward}"/>
		<input type="hidden" name="action" value="{$action}"/>
		<input type="hidden" name="step" value="{$step}"/>
		<input type="hidden" name="itemid" value="{$itemid}"/>
		<table class="data-form">
			<tr>
				<th width="90">当前操作</th>
				<td class="tr cred f_b">交易评价</td>
			</tr>
			<tr>
				<th width="90">交易打分</th>
				<td class="tr">
					<input type="radio" name="star" value="3" id="star_3" checked/><label for="star_3"> 好评 <img src="{SITE_URL}file/image/star3.gif" width="36" height="12" alt="" align="absmiddle"/></label>
					<input type="radio" name="star" value="2" id="star_2"/><label for="star_2"> 中评 <img src="{SITE_URL}file/image/star2.gif" width="36" height="12" alt="" align="absmiddle"/></label>
					<input type="radio" name="star" value="1" id="star_1"/><label for="star_1"> 差评 <img src="{SITE_URL}file/image/star1.gif" width="36" height="12" alt="" align="absmiddle"/></label>
				</td>
			</tr>
			<tr>
				<th width="90">详细评论</th>
				<td class="tr f_gray">
					<textarea onkeyup="S();" name="content" id="content" style="width:300px;height:60px;margin:0 0 6px 0;"></textarea><br/>
					请您对此次交易做出客观、公正的评论<br/>
					(内容限0至500字) 当前已经输入 <span style="color:red;" id="chars">0</span> 字
				</td>
			</tr>
			<tr>
				<th width="90"></th>
				<td class="tr">
					<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
				</td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">
		function check() {
			if ( Dd('content').value.length > 500 ) {
				alert('评论内容不能超过500字');
				return false;
			}
			return confirm('您确认提交此评论吗？提交后评论分数和内容将不可更改');
		}
		function S() {
			Inner('chars', Dd('content').value.length);
		}
	</script>
	<script type="text/javascript">s('trade');
	m('{$nav}');</script>
		{elseif $step == 'comment_detail'}
	<table class="data-form">
		<tr>
			<th width="90">当前操作</th>
			<td class="tr cred f_b">评价详情</td>
		</tr>
	</table>
	<div class="t2">买家评价{if $_username==$td[buyer]}(我的){/if}</div>
	<table class="data-form">
		{if $cm[seller_star]}
			<tr>
				<th width="90">买家评分</th>
				<td class="tr"><img src="{SITE_URL}file/image/star{$cm[seller_star]}.gif" width="36" height="12" alt="" align="absmiddle"/> {$STARS[$cm[seller_star]]}
					{if $_username == $td[seller] && !$cm[buyer_reply]}
						&nbsp;&nbsp;<a href="#exp" onclick="Ds('explain');" class="t">[解释]</a>
					{/if}
				</td>
			</tr>
			<tr>
				<th width="90">买家评论</th>
				<td class="tr">{nl2br($cm[seller_comment])}</td>
			</tr>
			<tr>
				<th width="90">评论时间</th>
				<td class="tr px11">{timetodate($cm[seller_ctime], 6)}</td>
			</tr>
			{if $cm[buyer_reply]}
				<tr>
					<th width="90">卖家解释</th>
					<td class="tr" style="color:#D9251D;">{nl2br($cm[buyer_reply])}</td>
				</tr>
				<tr>
					<th width="90">解释时间</th>
					<td class="tr px11">{timetodate($cm[buyer_rtime], 6)}</td>
				</tr>
			{/if}
			{else}
			<tr>
				<th width="90">买家评论</th>
				<td class="tr">暂未评论</td>
			</tr>
		{/if}
	</table>
	<div class="t2">卖家评价{if $_username==$td[seller]}(我的){/if}</div>
	<table class="data-form">
		{if $cm[buyer_star]}
			<tr>
				<th width="90">卖家评分</th>
				<td class="tr"><img src="{SITE_URL}file/image/star{$cm[buyer_star]}.gif" width="36" height="12" alt="" align="absmiddle"/> {$STARS[$cm[buyer_star]]}
					{if $_username == $td[buyer] && !$cm[seller_reply]}
						&nbsp;&nbsp;<a href="#exp" onclick="Ds('explain');" class="t">[解释]</a>
					{/if}
				</td>
			</tr>
			<tr>
				<th width="90">卖家评论</th>
				<td class="tr">{nl2br($cm[buyer_comment])}</td>
			</tr>
			<tr>
				<th width="90">评论时间</th>
				<td class="tr px11">{timetodate($cm[buyer_ctime], 6)}</td>
			</tr>
			{if $cm[seller_reply]}
				<tr>
					<th width="90">买家解释</th>
					<td class="tr" style="color:#D9251D;">{nl2br($cm[seller_reply])}</td>
				</tr>
				<tr>
					<th width="90">解释时间</th>
					<td class="tr px11">{timetodate($cm[seller_rtime], 6)}</td>
				</tr>
			{/if}
			{else}
			<tr>
				<th width="90">卖家评论</th>
				<td class="tr">暂未评论</td>
			</tr>
		{/if}
	</table>
	<div style="display:none;" id="explain">
		<div class="t2">我的解释</div>
		<form method="post" action="{$MOD[linkurl]}trade.php" onsubmit="return check();" id="dform">
			<input type="hidden" name="forward" value="{$forward}"/>
			<input type="hidden" name="action" value="{$action}"/>
			<input type="hidden" name="step" value="{$step}"/>
			<input type="hidden" name="itemid" value="{$itemid}"/>
			<table class="data-form">
				<tr>
					<th width="90"><span class="cred">*</span>我的解释</th>
					<td class="tr f_gray">
						<textarea onkeyup="S();" name="content" id="content" style="width:300px;height:60px;margin:0 0 6px 0;"></textarea><br/>
						请您对此次评价做出客观、合理的解释<br/>
						(内容限2至500字) 当前已经输入 <span style="color:red;" id="chars">0</span> 字
					</td>
				</tr>
				<tr>
					<th width="90"></th>
					<td class="tr">
						<input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<a name="exp"></a>
	<script type="text/javascript">
		function check() {
			if ( Dd('content').value.length < 2 ) {
				alert('解释内容不能少于2字');
				return false;
			}
			if ( Dd('content').value.length > 500 ) {
				alert('解释内容不能超过500字');
				return false;
			}
			return confirm('您确认提交此解释吗？提交后解释内容将不可更改');
		}
		function S() {
			Inner('chars', Dd('content').value.length);
		}
	</script>
	<script type="text/javascript">s('trade');
	m('{$nav}');</script>
	{/if}
	{elseif $action == 'order'}
<!--我发出的订单，我是买家-->
<div class="tt">
	<form action="{$MOD[linkurl]}trade.php">
		<input type="hidden" name="action" value="{$action}"/>
		{$fields_select}&nbsp;
		<input type="text" size="10" name="kw" value="{$kw}" title="关键词"/>&nbsp;
		{$status_select}&nbsp;
		{dcalendar('fromtime', $fromtime)} 至 {dcalendar('totime', $totime)}&nbsp;
		<input type="submit" value=" 搜 索 " class="btn"/>&nbsp;
		<input type="button" value=" 重 置 " class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?action={$action}';"/><br/>

		<div class="b10"></div>
		单号：<input type="text" size="10" name="itemid" value="{$itemid}"/>&nbsp;
		商品ID：<input type="text" size="10" name="mallid" value="{$mallid}"/>&nbsp;
		卖家：<input type="text" size="20" name="seller" value="{$seller}"/>&nbsp;
</div>
</form>
<div class="bd">
	<table cellpadding="1" cellspacing="0" class="tb">
		<tr>
			<th class="bg" width="60">缩略图</th>
			<th class="bg" >商品或服务</th>
			<th class="bg" width="60">金额</th>
			<th class="bg" width="80">卖家</th>
			<th class="bg"  width="{if $DT[im_web]}40{else}16{/if}">&nbsp;</th>
			<th class="bg"  width="75">下单时间</th>
			<th class="bg"   width="75">更新时间</th>
			<th class="bg"  width="90">状态</th>
		</tr>
		{loop $trades $k $v}
			<tr align="center"{if $k%2==1} bgcolor="#FAFAFA"{/if}>
				<td rowspan="2" height="70"><a href="{$v[linkurl]}" target="_blank"><img src="{if $v[thumb]}{$v[thumb]}{else}{CSSIMG_URL}/common/nopic50.gif{/if}" width="50" height="50" onerror="this.src=errimg;"/></a></td>
				<td align="left" style="padding:0 8px 0 8px;" class="f_b f_dblue"><a href="{$v[linkurl]}" target="_blank" class="t">{$v[title]}</a></td>
				<td class="f_price" title="商品价格：￥{$v[price]} x {$v[number]}件 = {$v[amount]}{if $v[fee]>0.1} {$v[fee_name]}:{$v[fee]}{/if}">{$v[money]}</td>
				<td class="px11"><a href="{userurl($v[seller], 'file=contact')}" target="_blank">{$v[seller]}</a></td>
				<td>{if $DT[im_web]}{Im::web($v[seller].'&mid=16&itemid='.$v[mallid])} {/if}<a href="message.php?action=send&touser={$v[seller]}" target="_blank"><img src="image/ico_message.gif" title="发送站内信" align="absmiddle"/></a></td>
				<td class="px11">{$v[addtime]}</td>
				<td class="px11">{$v[updatetime]}</td>
				<td>{$v[dstatus]}</td>
			</tr>
			<tr{if $k%2==1} bgcolor="#FAFAFA"{/if}>
				<td colspan="8" class="f_gray">
<span class="f_r">
{if $v[status] == 0}
	<input type="button" value="删 除" class="btn" onclick="if(confirm('确实要删除此交易吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
	{elseif $v[status] == 1}
	{if $DT[trade]}
		<a href="{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=pay&forward={$forward}" class="t" onclick="return confirm('确认订单无误，现在付款吗？');" target="_blank"><img src="{SITE_URL}api/trade/{$DT[trade]}/pay.gif" align="absmiddle" title="{$DT[trade_nm]}付款"/></a>
		{else}
		<input type="button" value="付 款" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=pay&forward={$forward}';"/>
	{/if}
	<input type="button" value="关闭交易" class="btn" onclick="if(confirm('确实要关闭此交易吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
	{elseif $v[status] == 3}

	{if $v[lefttime]}
		<span class="f_blue" title="如果逾期未处理，系统将自动付款给卖家"><img src="{SITE_URL}file/image/clock.gif" width="12" height="12"/> 距处理此订单还剩{$v[lefttime]}</span>&nbsp;
	<input type="button" value="确认到货" class="btn" onclick="if(confirm('确认已收到货且质量与数量无误吗？\n\n请注意:确认后您的钱将直接支付给卖家')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=receive_goods&forward={$forward}';"/>
	<input type="button" value="申请退款" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=refund&forward={$forward}';"/>
		{else}
		<span class="cred">订单处理已超时，等待卖家收款</span>&nbsp;
	{/if}
	{elseif $v[status] == 4}
	{if $v[seller_star]}
		<input type="button" value="评价详情" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=comment_detail&forward={$forward}';"/>
		{else}
		<input type="button" value="评 价" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=comment&forward={$forward}';"/>
	{/if}
	{elseif $v[status] == 9}
	<input type="button" value="删 除" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
{/if}
	<input type="button" value="订单详情" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=detail';"/>
&nbsp;
</span>
					&nbsp;
					<strong>单号：</strong>{$v[itemid]}&nbsp;&nbsp;
					<strong>单价：</strong>￥{$v[price]}&nbsp;&nbsp;
					<strong>数量：</strong>{$v[number]}件&nbsp;&nbsp;
					<strong>备注：</strong>{$v[note]}
				</td>
			</tr>
		{/loop}
		{if $trades}
			<tr align="center">
				<td height="30">&nbsp;</td>
				<td><strong>小计</strong></td>
				<td class="cred f_b px11">{$money}</td>
				<td colspan="5" align="left" class="cred">&nbsp;&nbsp;提示：如果交易中有任何问题，请与网站联系</td>
			</tr>
		{/if}
	</table>
</div>
<div class="pages">{$pages}</div>
<script type="text/javascript">s('trade');
m('action_order');</script>
	{else}
<!--我收到的订单，我是卖家-->
	{if $MG[trade_sell]}
	<div class="tt">
		<form action="{$MOD[linkurl]}trade.php">
			<input type="hidden" name="action" value="{$action}"/>
			{$fields_select}&nbsp;
			<input type="text" size="10" name="kw" value="{$kw}" title="关键词"/>&nbsp;
			{$status_select}&nbsp;
			{dcalendar('fromtime', $fromtime)} 至 {dcalendar('totime', $totime)}&nbsp;
			<input type="submit" value=" 搜 索 " class="btn"/>&nbsp;
			<input type="button" value=" 重 置 " class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?action={$action}';"/><br/>

			<div class="b10"></div>
			单号：<input type="text" size="10" name="itemid" value="{$itemid}"/>&nbsp;
			商品ID：<input type="text" size="10" name="mallid" value="{$mallid}"/>&nbsp;
			买家：<input type="text" size="20" name="buyer" value="{$buyer}"/>&nbsp;
		</form>
	</div>
	<div class="bd">
		<table cellpadding="1" cellspacing="0" class="tb">
			<tr>
				<th class="bg"  width="60">缩略图</th>
				<th class="bg" >商品或服务</th>
				<th class="bg"  width="60">金额</th>
				<th class="bg"  width="80">买家</th>
				<th class="bg"  width="{if $DT[im_web]}40{else}16{/if}">&nbsp;</th>
				<th class="bg"  width="75">下单时间</th>
				<th class="bg"  width="75">更新时间</th>
				<th class="bg"  width="90">状态</th>
			</tr>
			{loop $trades $k $v}
				<tr align="center"{if $k%2==1} bgcolor="#FAFAFA"{/if}>
					<td rowspan="2" height="70"><a href="{$v[linkurl]}" target="_blank"><img src="{if $v[thumb]}{$v[thumb]}{else}{CSSIMG_URL}/common/nopic50.gif{/if}" width="50" height="50" onerror="this.src=errimg;"/></a></td>
					<td align="left" style="padding:0 8px 0 8px;" class="f_b f_dblue"><a href="{$v[linkurl]}" target="_blank" class="t">{$v[title]}</a>{if $v[status] == 0} <img src="image/new.gif"/>{/if}</td>
					<td class="f_blue f_b px11" title="商品价格：￥{$v[price]} x {$v[number]}件 = {$v[amount]}{if $v[fee]>0.1} {$v[fee_name]}:{$v[fee]}{/if}">{$v[money]}</td>
					<td class="px11"><a href="{userurl($v[buyer], 'file=contact')}" target="_blank">{$v[buyer]}</a></td>
					<td>{if $DT[im_web]}{Im::web($v[buyer].'&mid=16&itemid='.$v[mallid])} {/if}<a href="message.php?action=send&touser={$v[buyer]}" target="_blank"><img src="image/ico_message.gif" title="发送站内信" align="absmiddle"/></a></td>
					<td class="px11">{$v[addtime]}</td>
					<td class="px11">{$v[updatetime]}</td>
					<td>{$v[dstatus]}</td>
				</tr>
				<tr{if $k%2==1} bgcolor="#FAFAFA"{/if}>
					<td colspan="8" class="f_gray">
<span class="f_r">
{if $v[status] == 0}
	<input type="button" value="确认订单" class="btn" onclick="if(confirm('确实要确认此订单吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=confirm_order&forward={$forward}';"/>
<input type="button" value="修改价格" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=edit_price';"/>
<input type="button" value="关闭交易" class="btn" onclick="if(confirm('确实要关闭此交易吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
	{elseif $v[status] == 1}
	<input type="button" value="关闭交易" class="btn" onclick="if(confirm('确实要关闭此交易吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
	{elseif $v[status] == 2}
	<input type="button" value="确认发货" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=send_goods';"/>
	{if !$DT[trade]}<input type="button" value="关闭交易" class="btn" onclick="if(confirm('确实要关闭此交易吗？此操作将不可撤销')) window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>{/if}
	{elseif $v[status] == 3}
	{if $v[lefttime]}
		<span class="f_blue"><img src="{SITE_URL}file/image/clock.gif" width="12" height="12"/> 距买家处理订单还剩{$v[lefttime]}</span>&nbsp;
	<input type="button" value="延长时间" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=add_time&forward={$forward}';"/>
		{else}
		<span class="f_blue">买家处理订单超时</span>
	<input type="button" value="直接收款" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=get_pay&forward={$forward}';"/>
	{/if}
	{elseif $v[status] == 4}
	{if $v[buyer_star]}
		<input type="button" value="评价详情" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=comment_detail&forward={$forward}';"/>
		{else}
		<input type="button" value="评 价" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=comment&forward={$forward}';"/>
	{/if}
	{elseif $v[status] == 8}
	<input type="button" value="删 除" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=close&forward={$forward}';"/>
{/if}
	<input type="button" value="订单详情" class="btn" onclick="window.location='{$MOD[linkurl]}trade.php?itemid={$v[itemid]}&action=update&step=detail';"/>
&nbsp;
</span>
						&nbsp;
						<strong>单号：</strong>{$v[itemid]}&nbsp;&nbsp;
						<strong>单价：</strong>￥{$v[price]}&nbsp;&nbsp;
						<strong>数量：</strong>{$v[number]}件&nbsp;&nbsp;
						<strong>备注：</strong>{$v[note]}
					</td>
				</tr>
			{/loop}
			{if $trades}
				<tr align="center">
					<td height="30">&nbsp;</td>
					<td><strong>小计</strong></td>
					<td class="f_blue f_b px11">{$money}</td>
					<td colspan="5" align="left" class="cred">&nbsp;&nbsp;提示：如果交易中有任何问题，请与网站联系</td>
				</tr>
			{/if}
		</table>
	</div>
	<div class="pages">{$pages}</div>
		{else}
	<br/><br/><br/><br/><br/>
	<center class="px14">当前共收到 <span class="cred">{$orders}</span> 个订单，请<a href="grade.php" class="t">升级您的会员级别</a>获取查看权限</center>
	{/if}
<script type="text/javascript">s('trade');
m('action');</script>
{/if}
</div>
{template 'footer', $module}